package com.example.leo.mycharmingstudent.mvp.mainpage;

import com.example.leo.mycharmingstudent.a0917.practice.ArticleEntity;
import com.example.leo.mycharmingstudent.mvp.source.IMVPTasksDataSource;
import com.example.leo.mycharmingstudent.mvp.source.MVPTasksRepository;

import java.io.IOException;

import okhttp3.Call;

/**
 * Created by Leo on 2020/11/10.
 */

public class MVPPresenter implements MVPContract.Presenter {

    private final MVPTasksRepository mMvpTasksRepository;
    private final MVPContract.View mView;

    public MVPPresenter(MVPTasksRepository mvpTasksRepository, MVPContract.View view) {
        this.mMvpTasksRepository = mvpTasksRepository;
        this.mView = view;

//        mView.setPresenter(this);
    }

    @Override
    public void start() {

    }

    @Override
    public void articleList(int currentPage) {
        mMvpTasksRepository.articleList(currentPage, new IMVPTasksDataSource.NetCallBack<ArticleEntity>() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(ArticleEntity entity) {
                mView.showArticleList(entity);
            }
        });
    }
}
